home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1 Issue 2
/
PDCD-1 - Issue 02.iso
/
_fonttools
/
fonttools
/
multifonts
/
!BBCFonts
/
!help
next >
Wrap
Text File
|
1991-03-16
|
9KB
|
203 lines
BBC FONT SELECTOR DOCUMENTATION
On the March 1991 disc - as well as in the Public Domain - there were some
examples of BBC Fonts. These are fonts that replace the normal character
set, and make life with your Archimedes a lot more varied.
{P}Normally, each font is loaded by double-clicking on its icon in the
filer. However, this is not particularly convenient because if you have
many fonts, the filer display becomes too large for comfort. Also, double-
clicking on an icon causes a large, unsightly box to fill the screen,
inviting you to press the space bar. As well as this, auto-booting a font
file is not particularly elegant and returning to the normal, Latin1 font
involves using the CLI.
{P}To sort out these small problems, and to make the handling of such fonts
easier, I have written a multi-tasking font selector for the Archimedes.
The program supports the !Help application, but is very easy to use anyway.
@XH = How to use the program
{P}Load the program in the usual RISC-OS way - by double clicking on the
'abc' icon - so as the program installs itself on the icon bar. If you
click select over this icon, a list of fonts will appear in a window. To
change the typeface, simply click select over the name of the required font.
The inverted icon shows you which font is currently selected.
{P}At first, you may only be able to select one of the six standard
typefaces - those being Latin1-4, Greek and BFont. These are not
particularly exciting, so you may be wandering how you can add other fonts -
such as Dungeon, IBM and Courier - to the list.
{P}This is very simple - just drag a BBC Font icon from the filer into the
Selector Window. If the list is not full - it can store up to fifty font
names - and the font has not already been installed, its name will be added
to the list. You can now select it as before. Note, however, that the font
file must reside in the application's directory or one of its sub-
directories, for example adfs::Apps20.$.!BBCFonts.Fonts. You will need to
copy the file into the application directory before installing it, if it is
not already there. By keeping all the fonts in one place, it means that if
you copy the application to another disc, all fonts will be copied as well.
{P}If you decide that, after all, you do not want a particular font to
appear in the list, click menu over the font name in question, and select
the 'Remove' option.
{P}Another facility offered by the program is a 'Default font' option - that
is, the font automatically selected whenever the program is loaded. To do
this, click with menu over the required font name, and select 'Default'.
This menu option becomes ticked and the font icon turns blue. The next time
you load the program, this font will be selected - but only if you save the
settings before you quit. This can be achieved by selecting 'Save' from the
menu, which stores the settings in a file called "<BBCFont$Dir>.Config".
{P}The config file, if present, is loaded automatically each time the
program is run. If you combine this facility with the machine's own
auto-booting function, you can select your favourite font by simply
inserting the right disc. By renaming the '!BBCFonts.AutoBoot' file as
'!BBCFonts.!Boot' the program will load when you click select over the drive
icon.
@XH = How the program works
{P}The program installs itself in the usual RISC-OS way when run. It then
goes into the the polling loop and waits for something to happen.
{P}The three main things of any interest that can happen are:
{*} the mouse is clicked in the window or on the 'abc' icon
{*} a file is dragged into the window
{*} a menu option is selected
{P}If the user clicks with select in the window, the function
FNwhere_am_i(x%,y%) is called. Here x% and y% represent the co-ordinates of
the mouse pointer relative to the top left hand corner of the window. This
is calculated by PROCget_win_info that uses the SYS "Wimp_GetWindowInfo"
call to work out its origins. FNwhere_am_i(x%,y%) takes this data and
returns either the font number that the mouse is over, or &FF if no font is
pointed at. The array fnt$() contains the font names according to their
numbers.
{P}The icons are drawn onto the window by the PROCredoing(main%) and
PROCdraw_icon(x%,y%) procedures. This method was used instead of creating
Wimp icons because more programming was required with a PROCcreate_icon
routine and the icon handle given would rarely be the same as the font
number if fonts were deleted.
{P}When select is clicked over one of these icons, current% is set to the
font number and the routine PROCselect_font(n%) is called. This either
issues a *Alphabet command if the font selected is a system font, or a *Load
command if the font needs to be loaded. It also calls
SYS"Wimp_ForceRedraw",-1,0,0,1280,1024 which redraws all on-screen windows.
For some reason, some fonts cause the icons around the windows to be changed
after loading. To return these to their normal shapes without affecting the
other characters in the set, simply press f12 followed by Return.
{P}If the user clicks with menu in the window,
PROCcreate_menu(title$,data$,menu%,y%) is called which creates the menu
contained in data$. Briefly, this holds the menu items separated by commas.
Each item can be prefixed with + or - meaning that the option is ticked or
dimmed respectively. The function FNtest_opt(test%,s$) inserts s$ into the
data string if the expression in test% is true. For example
@L = PROCcreate_menu("Title","Opt 1,"+FNtest_opt(h%=1,"+")+"Opt 2",menu%,y%)
{P}would create a two-option menu with the second option ticked if h% is 1.
{P}In the opening of a menu, open$ and open% are given values so that
PROCmenu_select, which is called when a menu item is selected, can determine
which function to call. Similarly, if PROCreopen_menu is called after
adjust was clicked on a menu, it uses open% to work out which menu it should
reopen.
{P}PROCmenu_select uses the data block provided as well as the open$
variable to call a function which carries out the necessary actions. For
example FNmain_0 removes a font, as the first item on the main menu is
'Remove'.
{P}The most complex part of the program, apart from the window refreshing
which uses a lot of formulas to place the right number if icons in the right
places, is the receive message section. If a file is dropped into the
program window, the program first finds out if the file in question is a
font file.
{P}If so, the program makes sure that the file is in a sub- directory of the
application directory. It does this by comparing the first part of the
filename with the system variable <BBBFont$Dir>. FNreadvar(var$) reads the
system variable and puts it into a Basic string. If the file does belong to
the application directory, the name is shortened by removing <BBCFont$Dir>.
This means that, should you ever move the application to another directory
or disc, it will still work.
{P}The filename left after the subtraction of the <BBCFont$Dir> part may be
something like 'NewFonts.AlienFont'. The name printed in the window is the
last part of this - 'AlienFont' - which is found by using the function
FNlastbit(file$). Finally, this name is checked with the last part of all
the others to make sure that the same font is not stored twice in the list.
{P}After this, the window's size is changed by PROCset_extent. This uses
the SYS "Wimp_SetExtent" command to set the size of the window so that it
can hold all the icons, but no more.
{P}Similarly, when FNmain_1, which removes a font, is called, PROCset_extent
is used, followed by SYS "Wimp_OpenWindow" and SYS "Wimp_RedrawWindow" so
that if the window gets smaller, this is shown on screen as well.
{P}The !Help system is supported in the usual way by responding to message
number &502 from the Wimp Manager. This gives full information on what
happens wherever the mouse is clicked.
{P}The only part of the program left to describe is the save routine -
FNmain_2. This uses the standard PRINT# commands to store the names of the
fonts, the number of fonts and the default font under the filename
<BBCFont$Dir>.Config. The PROCload_config routine finds out if such a file
has been saved, and if so it loads the font list along with the default
font.
{P}Most of the important procedures and functions have been mentioned above
- the rest are just general wimp housekeeping commands. There are also a
few major, global variables, which are:
default% - the default font number
current% - the current font number
nofont% - the total number of fonts
win_height% - the height of the main window
main% - the main window handle
info% - the info window handle
menu% - the menu data block
curbuf% - the buffer in which indirected icon data is stored
block% and q% - general purpose data blocks
fnt$() - holds the last part(s) of a font file name, e.g.
"AlienFont" = "<BBCFont$Dir>.AlienFont"
"NewFonts.AlienFont" = "<BBCFont$Dir>.NewFonts.AlienFont"
program documentation sprites obey files
-------------------------------------------
ë nineteen ninety one ë richard blythe
Mr Richard Blythe
35, Carminow Way
Newquay
Cornwall
TR7 3AZ
England
assorted bbc fonts
------------------
ë nineteen ninety ë skyfall public domain disc h13
ë nineteen ninety one ë the micro user march subscription disc
end